package edu.zhuravlev.trainingbot.it;


import edu.zhuravlev.trainingbot.repository.UserRepository;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Update;

import static edu.zhuravlev.trainingbot.it.BotTestUtils.TEST_CHAT;
import static edu.zhuravlev.trainingbot.it.BotTestUtils.getTestUpdateWithMessage;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;


public class CommandsIT extends RootIT {

    @Autowired
    private UserRepository userRepository;

    @Test
    void context_up_test() {
        assertEquals(1, 1);
    }

    @Test
    @SneakyThrows
    void start_command_test() {
        Update startUpdate = getTestUpdateWithMessage("/start");

        receivedUpdate(startUpdate);

        verify(telegramClient, times(1)).execute(any(SendMessage.class));
        assertTrue(userRepository.existsById(TEST_CHAT));
    }

}
